import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '@/views/HomeView.vue'
import type { App } from 'vue'
import { getPageTabAppUrls } from '@/apps/pages/init'

import Auth from '@/apps/auth/views'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView
    },
    {
      path: '/welcome',
      name: 'welcome',
      component: () => import('@/views/WelcomeView.vue')
    },
    {
      path: '/auth',
      component: Auth.Views
    },
    ...getPageTabAppUrls(),

    {
      path: '/:pathMatch(.*)*',
      component: () => import('@/views/excepts/Err404View.vue'),
      name: 'Err404'
    }
  ]
})

// RouteRecordRaw

function setupRouter(app: App<Element>) {
  app.use(router)
}
export { router, setupRouter }
